package com.xwyzsn.backend.job.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xwyzsn.backend.job.common.Result;
import com.xwyzsn.backend.job.entity.Student;
import com.xwyzsn.backend.job.mapper.StudentMapper;
import com.xwyzsn.backend.job.service.impl.StudentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xwyzsn
 * @since 2023-03-03
 */
@RestController
@RequestMapping("/job/student")
@CrossOrigin(origins = "*", maxAge = 3600)
public class StudentController {
    @Autowired
    private StudentServiceImpl studentServiceimpl;
    @GetMapping("/getinfo")
    public Result getInfo(@RequestParam("uname") String uname){
        return studentServiceimpl.getInfo(uname);
    }
    @PostMapping("/update")
    public Result update(
                         @RequestParam("snum") String snum,
                         @RequestParam("tel") String tel,
                         @RequestParam("qq") String qq,
                         @RequestParam("confirmPassword") String confirmPassword,
                         @RequestParam("email") String email){
        return studentServiceimpl.update(snum, confirmPassword,email,tel,qq);
    }
    @GetMapping("getdeptstudent")
    public Result getDeptStudent(@RequestParam("dept") String dept){
        return studentServiceimpl.getDeptStudent(dept);
    }
    @PostMapping("/updateall")
    public Result updateAll(
            @RequestParam("snum") String snum,
            @RequestParam("sname") String sname,
            @RequestParam("age") Integer age,
            @RequestParam("tel") String tel,
            @RequestParam("qq") String qq,
            @RequestParam("confirmPassword") String confirmPassword,
            @RequestParam("email") String email,
            @RequestParam("classnum") String classnum ,
            @RequestParam("dept") String dept,
            @RequestParam("major") String major){
        return studentServiceimpl.updateAll(snum,sname,age,tel,qq,confirmPassword,email,classnum,dept,major);
    }
    @GetMapping("deletebatch")
    public Result deleteBatch(@RequestParam("sids") List<Integer> sids){
        return studentServiceimpl.deleteBatch(sids);
    }

    @PostMapping("uploadcsv")
    public Result uploadCsv(@RequestPart("file") final MultipartFile uploadfile ) throws IOException {
        return studentServiceimpl.uploadCsv(uploadfile);
    }


}
